package com.homework;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ServletVip extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int money = 1000;
        String name = req.getRequestURI();
        String s = name.substring(name.lastIndexOf("/")+1);

        if(s.equals("vip")){
            System.out.println("原价为"+money+"vip会员打九折,价格为"+(money*0.9));
        }else if(s.equals("vvip")) {

            System.out.println("原价为" + money + "vip会员打七折,价格为" + (money * 0.7));
        }else{
            System.out.println("价格为"+money);
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
